package fr.mma.achievement.dao;

import java.util.List;

import com.googlecode.objectify.ObjectifyService;

import fr.mma.achievement.model.persistence.Achievement;
import fr.mma.livraison.model.persistence.Developpeur;
import fr.mma.socle.dao.CommonDao;

public class AchievementDao extends CommonDao<Achievement> {
	public AchievementDao() {
		super(Achievement.class);
	}

	static {
		ObjectifyService.register(Achievement.class);
	}

	public Achievement getOrCreate(final String identifiant) {
		Achievement found = ofy().find(Achievement.class, identifiant);
		if (found == null) {
			found = new Achievement(identifiant);
		}
		return found;
	}
	
	
	public List<Achievement> getByDeveloppeur(final Developpeur developpeur) {
		return ofy().query(Achievement.class).filter("developpeur", developpeur).list();
	}

	public Achievement get(final String identifiant) {
		return ofy().find(Achievement.class, identifiant);
	}
}
